import fetch from 'common/src/utils/fetch';

function listFailScorePage(data) {
    return fetch({
        url: '/api/scoremanagementservice/studentScoreQuery/listFailScorePage',
        method: 'post',
        data: data
    });
}

function findStuAndTeaInfo(studentId) {
    return fetch({
        url: '/api/studentservice/studentInfo/findStuAndTeaInfoForScore',
        method: 'get',
        params: {
            studentId: studentId
        }
    });
}
/**
 * 不及格成绩导出
 * @param {} data 导出需要参数，页面筛选面板所有参数及学号筛选值及选定行数
 */
function exportFailScore(params, studentIds = '') {
    let url = '/api/scoremanagementservice/studentScoreQuery/failScoreExport';
    let string = '';
    for (var key in params) {
        if (params[key] === '') {
            continue;
        }
        string += `${key}=${params[key]}&`;
    }
    let restApi = `${url}?${string.substring(0, string.length - 1)}`;
    return fetch({
        url: restApi,
        method: 'post',
        headers: { 'Content-Type': 'text/plain;charset=UTF-8' },
        responseType: 'blob',
        data: studentIds
    });
}

const failScoreManageApi = {
    listFailScorePage: listFailScorePage,
    findStuAndTeaInfo: findStuAndTeaInfo,
    exportFailScore: exportFailScore
};

export default failScoreManageApi;
